home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / antispam / RazorAgent_SDK / razor-agents-sdk-2.03.exe / URI-1.19 / t / heuristic.t < prev    next >
Encoding:
Text File  |  2002-01-17  |  2.6 KB  |  95 lines

  1. if (-f "OFFLINE") {
  2.    print "1..0";
  3.    exit;
  4. }
  5.  
  6. print "1..15\n";
  7.  
  8. use URI::Heuristic qw(uf_urlstr uf_url);
  9. if (shift) {
  10.     $URI::Heuristic::DEBUG++;
  11.     open(STDERR, ">&STDOUT");  # redirect STDERR
  12. }
  13.  
  14. print "not " unless uf_urlstr("http://www.sn.no/") eq "http://www.sn.no/";
  15. print "ok 1\n";
  16.  
  17. if ($^O eq "MacOS") {
  18.     print "not " unless uf_urlstr("etc:passwd") eq "file:/etc/passwd";
  19. } else {
  20. print "not " unless uf_urlstr("/etc/passwd") eq "file:/etc/passwd";
  21. }
  22. print "ok 2\n";
  23.  
  24. if ($^O eq "MacOS") {
  25.     print "not " unless uf_urlstr(":foo.txt") eq "file:./foo.txt";
  26. } else {
  27. print "not " unless uf_urlstr("./foo.txt") eq "file:./foo.txt";
  28. }
  29. print "ok 3\n";
  30.  
  31. print "not " unless uf_urlstr("ftp.aas.no/lwp.tar.gz") eq "ftp://ftp.aas.no/lwp.tar.gz";
  32. print "ok 4\n";
  33.  
  34. if($^O eq "MacOS") {
  35. #  its a weird, but valid, MacOS path, so it can't be left alone
  36.     print "not " unless uf_urlstr("C:\\CONFIG.SYS") eq "file:/C/%5CCONFIG.SYS";
  37. } else {
  38. print "not " unless uf_urlstr("C:\\CONFIG.SYS") eq "file:C:\\CONFIG.SYS";
  39. }
  40. print "ok 5\n";
  41.  
  42. if (gethostbyname("www.netscape.com")) {
  43.     # DNS probably work, lets run test 6..8
  44.  
  45.     $URI::Heuristic::MY_COUNTRY = "bv";
  46.     print "not " unless uf_urlstr("perl/camel.gif") eq "http://www.perl.com/camel.gif";
  47.     print "ok 6\n";
  48.  
  49.     $URI::Heuristic::MY_COUNTRY = "uk";
  50.     print "not " unless uf_urlstr("perl/camel.gif") eq "http://www.perl.co.uk/camel.gif";
  51.     print "ok 7\n";
  52.    
  53.     $ENV{URL_GUESS_PATTERN} = "www.ACME.org www.ACME.com";
  54.     print "not " unless uf_urlstr("perl") eq "http://www.perl.org";
  55.     print "ok 8\n";
  56.  
  57. } else {
  58.     # don't make the inocent worry
  59.     print "Skipping test 6-8 because DNS does not work\n";
  60.     for (6..8) { print "ok $_\n"; }
  61.  
  62. }
  63.  
  64. {
  65. local $ENV{URL_GUESS_PATTERN} = "";
  66. print "not " unless uf_urlstr("perl") eq "http://perl";
  67. print "ok 9\n";
  68.  
  69. print "not " unless uf_urlstr("http:80") eq "http:80";
  70. print "ok 10\n";
  71.  
  72. print "not " unless uf_urlstr("mailto:gisle\@aas.no") eq "mailto:gisle\@aas.no";
  73. print "ok 11\n";
  74.  
  75. print "not " unless uf_urlstr("gisle\@aas.no") eq "mailto:gisle\@aas.no";
  76. print "ok 12\n";
  77.  
  78. print "not " unless uf_urlstr("Gisle.Aas\@aas.perl.org") eq "mailto:Gisle.Aas\@aas.perl.org";
  79. print "ok 13\n";
  80.  
  81. print "not " unless uf_url("gopher.sn.no")->scheme eq "gopher";
  82. print "ok 14\n";
  83.  
  84. print "not " unless uf_urlstr("123.3.3.3:8080/foo") eq "http://123.3.3.3:8080/foo";
  85. print "ok 15\n";
  86. }
  87.  
  88. #
  89. #print "not " unless uf_urlstr("some-site") eq "http://www.some-site.com";
  90. #print "ok 15\n";
  91. #
  92. #print "not " unless uf_urlstr("some-site.com") eq "http://some-site.com";
  93. #print "ok 16\n";
  94. #
  95.